package com.dong.repeatsubmit;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StopWatch;

import java.util.Random;
import java.util.concurrent.*;
@Slf4j
public class OneFutureDemo {
//    public static void main(String[] args) {
//        ExecutorService executorService= Executors.newFixedThreadPool(10);
//        Future<Integer> future = executorService.submit(new changeSkin<Integer>());
//        StopWatch stopWatch = new StopWatch();
//        stopWatch.start();
//        try {
//            future.get(500,TimeUnit.MILLISECONDS);
//        } catch (TimeoutException e) {
//            log.info("耗时:{}",stopWatch.prettyPrint());
//            log.info("执行时间过长了");
//        } catch (InterruptedException e) {
//            log.info("执行中断异常:{}",e);
//        } catch (ExecutionException e) {
//            log.info("线程执行异常:{}",e);
//        }
//        executorService.shutdown();
//
//    }
//
//    static class changeSkin<I extends Number> implements Callable<Integer> {
//        @Override
//        public Integer call() throws Exception {
//            Thread.sleep(1000);
//            return new Random().nextInt();
//        }
//    }
    
}